package com.se2.antiqueexhibition.Controller;

import com.se2.antiqueexhibition.Service.ActivityService;
import com.se2.antiqueexhibition.Service.UserService;
import com.se2.antiqueexhibition.pojo.Activity;
import com.se2.antiqueexhibition.pojo.User;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping
public class ActivityController {
    @Resource
    private ActivityService activityService;
    @Resource
    private UserService userService;

    @RequestMapping("/event")
    public String getAllActivities(ModelMap model, HttpSession session) {
        System.out.println("控制层调用成功");
        List<Activity> activities = activityService.getAllActivities();
        model.put("activities", activities);
        return "events";
    }

    @GetMapping("/eventdetails/{id}")
    public String getActivities(@PathVariable int id,ModelMap model) {
        Activity activity = activityService.getActivityById(id);
        model.put("activity", activity);
        System.out.println(activity.getTitle());
        return "eventdetails";
    }

}
